import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routes = [
  {
    path: '/',
    redirect: "login"
  },
  // 登录
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login.vue')
  },
  // 首页
  {
    path: '/home',
    name: 'home',
    component: () => import('../views/home.vue'),
    redirect: "/home/xi",
    children: [
      // 系统首页
      {
        path: 'xi',
        name: 'xi',
        component: () => import('../views/xi.vue')
      },
      // 店铺中心  商家配置
      {
        path: 'Seller/configs',
        name: 'SellerConfigs',
        component: () => import('../views/dian/sahng.vue')
      },
      // 店铺中心  店铺资金
      {
        path: 'Seller/money_logs',
        name: 'SellerMoney_logs',
        component: () => import('../views/dian/dian.vue')
      },
      // 店铺中心  订单结算
      {
        path: 'Seller/order_settlements',
        name: 'SellerOrder_settlements',
        component: () => import('../views/dian/ding.vue')
      },
      // 店铺中心  资金提现
      {
        path: 'Seller/cashes',
        name: 'SellerCashes',
        component: () => import('../views/dian/zi.vue')
      },
      // 商品中心  商品管理
      {
        path: 'Seller/goods',
        name: 'SellerGoods',
        component: () => import('../views/shang/guan.vue')
      },
       // 商品中心  商品管理   添加商品
       {
        path: 'Seller/goods/chose_class',
        name: 'SellerGoodsChose_class',
        component: () => import('../views/shang/guan-list.vue')
      },
      // 商品中心  商品规格
      {
        path: 'Seller/goods_attrs',
        name: 'SellerGoods_attrs',
        component: () => import('../views/shang/gui.vue')
      },
      // 商品中心  商品规格   添加  编辑
      {
        path: 'Seller/goods_attrs/From',
        name: 'SellerGoods_attrsFrom',
        component: () => import('../views/shang/gui-from.vue')
      }
    ]
  }
]
const router = new VueRouter({
  routes
})
router.beforeEach((to, from, next) => {
  if (localStorage.getItem("token")) {
    next();
  } else {
    if (to.path == "/login") {
      next();
    } else {
      next("/login")
    }
  }
})
export default router